import { createHashHistory } from "history";

const debounce = (func: any, delay: number) => {
  let timer: NodeJS.Timeout;
  return function (...args: any) {
    if (timer) {
      clearTimeout(timer);
    }
    timer = setTimeout(() => {
      // @ts-ignore
      func.apply(this, args);
      clearTimeout(timer);
    }, delay);
  };
};

let historyHandler = createHashHistory();

export { debounce, historyHandler };
